package com.winit.schedule.core.repository.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import com.winit.schedule.core.task.ScheduleTaskDefine;

public class TaskTrackerEntity implements Serializable {

    /**
     * 
     */
    private static final long       serialVersionUID = -148574495964596021L;

    private String                  taskTrackerUuid;

    private String                  ip;

    private String                  hostname;

    private String                  taskGroup;

    private long                    registerTime;

    private long                    heartbeatTime;

    /**
     * 暂未使用
     */
    private int                     availableThreads = -1;

    /**
     * taskTracker对应的任务定义信息
     */
    private Set<ScheduleTaskDefine> taskDefines      = new HashSet<ScheduleTaskDefine>();

    /**
     * 辅助字段，远程调用超时时间（单位：毫秒）,默认值：3000毫秒
     */
    private long                    rpcTimeout       = 3000;

    public TaskTrackerEntity(){

    }

    public TaskTrackerEntity(String taskTrackerUuid, String ip, String hostname){
        this.taskTrackerUuid = taskTrackerUuid;
        this.ip = ip;
        this.hostname = hostname;
    }

    public String getTaskTrackerUuid() {
        return taskTrackerUuid;
    }

    public void setTaskTrackerUuid(String taskTrackerUuid) {
        this.taskTrackerUuid = taskTrackerUuid;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getHostname() {
        return hostname;
    }

    public void setHostname(String hostname) {
        this.hostname = hostname;
    }

    public String getTaskGroup() {
        return taskGroup;
    }

    public void setTaskGroup(String taskGroup) {
        this.taskGroup = taskGroup;
    }

    public long getHeartbeatTime() {
        return heartbeatTime;
    }

    public void setHeartbeatTime(long heartbeatTime) {
        this.heartbeatTime = heartbeatTime;
    }

    public long getRegisterTime() {
        return registerTime;
    }

    public void setRegisterTime(long registerTime) {
        this.registerTime = registerTime;
    }

    public int getAvailableThreads() {
        return availableThreads;
    }

    public void setAvailableThreads(int availableThreads) {
        this.availableThreads = availableThreads;
    }

    public Set<ScheduleTaskDefine> getTaskDefines() {
        return taskDefines;
    }

    public void setTaskDefines(Set<ScheduleTaskDefine> taskDefines) {
        this.taskDefines = taskDefines;
    }

    public long getRpcTimeout() {
        return rpcTimeout;
    }

    public void setRpcTimeout(long rpcTimeout) {
        this.rpcTimeout = rpcTimeout;
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof TaskTrackerEntity)) {
            return false;
        }
        TaskTrackerEntity other = (TaskTrackerEntity) o;
        if (this.taskTrackerUuid.equals(other.taskTrackerUuid)) {
            return true;
        }
        return false;
    }

    public int hashCode() {
        int hashCode = 31 * 17 + this.taskTrackerUuid.hashCode();
        hashCode = hashCode * 31 + this.ip.hashCode();
        hashCode = hashCode * 31 + this.hostname.hashCode();
        return hashCode;
    }
}
